package com.atguigu.gmall.file;

import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

import java.io.IOException;

/**
 * @author ：MJS
 * @date ：Created in 2021/5/10  13:51
 * @description：TODO
 */

public class FileUploadDemo {
    public static void main(String[] args) throws Exception {

        String path = ClassUtils.getDefaultClassLoader().getResource("fds_client.conf").getPath();
        //0.配置跟踪器的ip：port
        ClientGlobal.init(path);
        //1.创建TrackerClient客户端   192.168.6.105
        TrackerClient trackerClient =new TrackerClient();
        //2.连接TrackerServer端
        TrackerServer trackerServer = trackerClient.getConnection();
        //3.创建存储节点和客户端
        StorageServer storageServer=null;
        StorageClient1 storageClient1=new StorageClient1(trackerServer,storageServer);
        //4.上传文件
        String fileId = storageClient1.upload_file1("D:\\test\\xiong.jpg",
                "jpg", null);
        System.out.println(fileId);
    }
}
